home *** CD-ROM | disk | FTP | other *** search
-
- ;All user option references are LIGHT BLUE
-
- ;get options available
-
- get_options:
- mov es,ax,cs ;copy code segment
- cmp b chart_flag,0 ;have chart variables been intialised?
- jne >b1 ;check if getting new box if they have
-
- ;intialise flowchart variables
-
- xor ax,ax ;load zero
- mov b chart_flag,2 ;indicate getting new box data
- mov w box_save,ax ;indicate not branching
- mov w key_option,ax ;indicate not choosing a route
- mov w insert_mode,ax ;clear insert mode
- mov w box_to_subchart,ax ;indicate not choosing subchart
- mov w subchart_link,ax ;clear subchart follow box
- mov w sub_stack,top_stack ;set subchart stack pointer to top
- mov b message,al ;clear bottom line message buffer
-
- ;make first box in chart current box
-
- mov w current_box,ax ;clear current box
- mov dx,ax
- mov ax,first_box
- mov w next_box,ax ;store first box number
- mov bx,parent ;clear parent element
- call store_box_par ;clear parent parameter box
- xor bp,bp ;load current box
- mov b box_made,0ffh ;set flag
-
- ;check if getting box data
-
- b1:
- cmp b chart_flag,2 ;is it?
- if ne jmp long >b1 ;clear route string if not
- test b box_made,1 ;get new box data?
- je >b2 ;make new box current box if not
-
- ;create new box
-
- test b box_made,2 ;make a new box?
- je >a1 ;get new box pointer if not
- call make_box ;create new box
- es mov w[di],bp ;store it in new box
- mov bx,parent ;load offset to parent element
- call get_current_box_par ;get current box parent box
- es mov w[bx+di],ax ;store in as new box parent
- jmp >a2 ;get box descripter from user
-
- ;get field descripter
-
- a1:
- mov ax,w next_box ;load new box
- call get_box ;get its pointer
- a2:
- call writexy ;write prompt to bottom line
- db 25,24
- db 'Please enter box descripter',0
- mov b s,0 ;clear descripter string buffer
- call get_string ;get descripter string
- dw s ;destination buffer
- db 128,0 ;maximum string length
-
- ;copy string to buffer
-
- es mov w[di+descripter_length],cx ;store descripter length in box
- es mov ax,w[di+descripter] ;load address of descripter store
- es mov dx,w[di+descripter+2]
- call get_pointer ;convert it to pointer
- add w start_free_memory,cx ;move address to end of data
- adc w start_free_memory+2,0
- rep
- movsb ;copy string
-
- ;clear box child pointer
-
- mov ax,w next_box ;load next box
- mov bx,child ;load element offset
- xor dx,dx ;load zero
- call store_box_par ;clear child pointer
-
- ;make current box new box
-
- b2:
- mov b box_made,0ffh ;set new box flag
- xor ax,ax ;load zero
- mov b new_chart,al
- mov ax,w next_box ;load next box number
- mov bp,ax ;store it as current box
- inc w next_box ;increment new box number
-
- ;clear route variables
-
- b1:
- mov es,ax,cs ;copy segment to workspace
- xor ax,ax ;load zero
- cmp b chart_flag,2 ;reset route variables?
- jb >a1 ;check if to reset mode flag if not
- mov di,o option_routes ;load offset to extra option routes
- stosw ;clear them
- stosw
- stosw
- stosw
-
- ;indicate no routes selected
-
- mov b route_string,al ;clear route string
- mov w current_route,ax ;indicate no routes selected
- a1:
- cmp b chart_flag,3 ;reset mode flag?
- if e mov w insert_mode,ax ;reset mode flag
-
- ;clear option variables
-
- call clear_options ;clear options string
- mov w first_route,yes ;store first fixed route
- call get_current_real_routes ;get total real routes for current box
-
- ;check if any routes exist in current box
-
- cmp w key_option,0 ;is user choosing a route?
- if ne jmp long >b1 ;check for route options if yes
- mov b link_string,0 ;clear routes link string
- mov w route_exists,0 ;indicate no existing routes
- mov ax,w routes+yes ;are there any existing routes?
- or ax,w routes+no
- if ne inc w route_exists ;indicate there is a existing route
-
- ;set up flag indicating route(s) exists but no routes selected
-
- mov ax,w current_route ;load current route
- call inv_sgn ;get inverse sign of routes flag
- mul w route_exists ;multiply it by existing routes flag
- mov bx,ax ;save flag
- mov ax,w box_save ;load occupied else flag
- call inv_sgn ;get doing nothing flag
- mul bx ;store flag indicating route(s) exists
- mov w route_flag,ax ;but not selected and nothing else doing
-
- ;check if occupied else, and if so whether current box is the
- ;same as main box
-
- mov ax,w box_save ;load main box store/flag
- or ax,ax ;is flowchart dormant?
- je >b4 ;check for create/cancel option if it is
- cmp ax,bp ;is current box same as main box?
- jne >a1 ;check if route selected if not
- cmp ax,w subchart_link ;is box subchart follow box?
- jne >b4 ;check for create/cancel option if not
- mov b flag,0ffh ;indicate no routes point to current box
- ;from main box
-
- ;check if there is a route selected
-
- a1:
- cmp w current_route,0 ;is there a route selected?
- je >b3 ;check if copying subchart if not
- cmp w box_to_subchart,0 ;is user choosing subchart?
- jne >b3 ;check if on same level if yes
-
- ;get pointer to current box
-
- call get_box ;get box pointer
- mov ax,bp ;load current box
- mov bx,w current_route ;load current route
- mov cx,2 ;load other routes count
-
- ;check if any routes point to main box
-
- a1:
- add bx,2 ;move to next route
- cmp bx,no+2 ;wrap?
- if e mov bx,yes ;load first route offset
- es cmp w[di+bx],ax ;does route point to current box?
- if e mov b flag,0 ;indicate route points to current box
- loop a1 ;decrement loop count
-
- ;check if any routes of current box point to main box
-
- cmp b flag,0 ;do any routes point to current box?
- je >b2 ;check for create/cancel option if yes
- b3:
- mov dx,w routes+parent ;save it
-
- ;check if current box is in same chart as main box
-
- mov bx,parent ;load element
- cmp w box_to_subchart,0 ;is a copied subchart being linked?
- jne >a1 ;check if box is parent if it is
- cmp w insert_mode,0 ;is insert mode on?
- jne >a2 ;write main box to link string if it is
- mov ax,w box_save ;load main box
- call get_box_par ;get its parent box
- cmp ax,dx ;is its parent same as current box?
- je >a2 ;write main box to link string if it is
- b4:
- jmp >b2 ;check for create/cancel option
-
- ;check if box is parent of subchart
-
- a1:
- mov ax,w routes+child ;load current box child pointer
- or ax,ax ;is there a child linked to current box?
- je >b2 ;check for create/cancel option if not
- call get_box_par ;get parent of child of current box
- cmp ax,bp ;does it point to current box?
- jne >b2 ;check for cancel/create option if not
- cmp w route_exists,0 ;is there a route from box
- Je >B2 ;check for create/cancel option if not
-
- ;flag link option available
-
- a2:
- call create_link_string ;create link string for descripter
- inc b option_array+2 ;write link option
-
- ;check if create or cancel option is available
-
- b2:
- mov ax,w route_flag ;load route exists flag
- add ax,w insert_mode ;add it to mode flag
- add ax,w box_save ;add it to main box
- cmp ax,w box_save ;is create or cancel option available?
- jne >a1 ;check if doing anything if not
- cmp w sub_stack,top_stack ;is stack empty?
- jne >a1 ;check for branch option if not
- call check_memory ;check if sufficient memory
- if nc inc b option_array+4 ;write create/cancel option
-
- ;check if flowchart is dormant
-
- a1:
- cmp w box_save,0 ;is it?
- jne >b2 ;check for single option if not
- cmp sub_stack,top_stack ;is user viewing copied subchart?
- if ne jmp long >b1 ;check route options if yes
- cmp w route_flag,0 ;does route exist without any selected?
- jne >a1 ;check for delete option if not
- mov ax,w routes ;load neighbour box
- or ax,w route_exists ;is there another box?
- if ne inc b option_array+6 ;write branch option if there is
-
- ;add insert, renumber and load chart options
-
- a1:
- call check_memory ;check if sufficient memory
- jc >a1 ;don't allow inserting if out of memory
- inc b option_array+10 ;add insert option to options array
- cmp b chart_active,080h ;are we in dos shell?
- if ne inc b option_array+38 ;add renumber chart option if not
-
- ;check if delete option is available
-
- a1:
- cmp w current_route,0 ;are any routes selected?
- jne >b3 ;check for insert option if they are
- mov ax,w routes+child ;load child chart
- or ax,ax ;is there a child chart?
- je >a1 ;check for delete option if not
- mov bx,parent ;load parent offset
- call get_box_par ;get parent of child chart
-
- ;check if sub-chart is copied
-
- cmp ax,bp ;is chart copied
- jne >a1 ;check fixed route count if it is
- cmp w real_routes,1 ;is there more than one fixed route
- ja >b1 ;check for route options if there is
- je >b2 ;check for single option if one route
- cmp w routes,first_box ;is box isolated?
- jae >b2 ;don't delete box if not
-
- ;check if parent box is isolated
-
- mov ax,w routes+parent ;get parent box
- call get_box ;get pointer to box
- es cmp w[di+child],bp ;is parent box maternal?
- jne >b2 ;don't allow box to be deleted if not
- jmp >a2 ;flag delete option
- a1:
- cmp w real_routes,1 ;is there more than one?
- ja >b2 ;check for single option if yes
- a2:
- inc b option_array+8 ;write delete option if not
-
- ;check if single option is available
-
- b2:
- cmp w current_route,0 ;is there a current route selected?
- je >b1 ;check for route options if not
- b3:
- mov ax,w insert_mode ;load insert flag
- dec ax ;decrement it
- mov bx,w box_save ;load main box
- or ax,ax ;is flowchart dormant?
- if e mov bx,ax ;load zero
- mov ax,w box_save ;load main box
- sub ax,bx ;subtract occupied mode
- sub ax,w routes+no ;subtract decision routes flag
- cmp ax,w box_save ;is single option available?
- if e inc b option_array+12 ;write single option if it is
-
- ;check if any of the decision route/options are available
-
- b1:
- mov b flag,0ffh ;set flag
- cmp w routes+no,0 ;is box decision box?
- jne >a1 ;write route options if it is
- cmp w routes+yes,0 ;is there a route?
- je >a1 ;write route options if there is
- b2:
- jmp long >b1 ;check if there is a key option if not
-
- ;write routes options to options string
-
- a1:
- mov b flag,0 ;clear forward flag
- mov ax,w box_save ;load main box
- call sgn ;get its sign
- mov bx,ax ;save it
- mov ax,w insert_mode ;load occupied flag
- call sgn ;get its sign
- sub bx,ax ;subtract it from main box sign
- cmp bx,1 ;is current route option available?
- if ne or b flag,4 ;indicate current route not available
-
- ;check if selecting route
-
- mov ax,w insert_mode ;calculate if selecting a route for
- inc ax ;other function
- mul w box_save
- sub ax,w box_save
- mov bx,w box_save
- sub bx,ax
- or bx,bx
- je >a1 ;select route if option available
- cmp sub_stack,top_stack ;is stack empty?
- if e or b flag,2 ;indicate choosing route for other fn
- a1:
- xor si,si ;load previous route
- mov cx,2 ;load loop count
-
- ;check if route is selected route
-
- a1:
- mov w route_exists_flag,0 ;indicate route isnt linked
- add si,2 ;move to next route
- mov di,w[si+routes]
- cmp si,w current_route ;is route route selected?
- jne >a4 ;check if route exists if not
- test b flag,4 ;is current route available?
- jne >a2 ;decrement loop count if not
-
- ;check if route exists
-
- a4:
- cmp w key_option,0 ;is user choosing a route?
- jne >a4 ;check route option if yes
- cmp di,1 ;is there a route?
- jbe >a3 ;check route option if not
- inc w route_exists_flag ;indicate route is active
- jmp >a5 ;check if there is a extra route option
-
- ;if key option is relinquish then check for fixed route
-
- a4:
- cmp di,1 ;is there a route?
- jbe >a6 ;decrement loop count if not
- a3:
- test b flag,2 ;choosing route for copied subchart?
- je >a5 ;set route option if it is
-
- ;check if any extra routes
-
- a6:
- cmp w[si+option_routes],0 ;is route an extra option?
- je >a2 ;decrement loop count if not
-
- ;write route option to options string
-
- a5:
- push si ;save route
- add si,12 ;calculate option number
- mov dx,w route_exists_flag ;load route exists flag
- add w option_array,dx ;add it to total routes count
- inc dx ;adjust it
- mov w[si+option_array],dx ;write route option
- pull si ;restore route
-
- ;decrement loop count
-
- a2:
- loop a1 ;decrement loop count
-
- ;check if there is a key option
-
- b1:
- mov si,w key_option ;load flag
- or si,si ;is user choosing a route?
- je >a1 ;check previous option if not
- inc b[si+option_array] ;write it to option string
- jmp long >b1 ;set current route
-
- ;check if previous option is available
-
- a1:
- cmp w routes,0 ;is there a neighbour box?
- je >a1 ;check for subchart option if nom
- cmp w insert_mode,0 ;is flowchart dormant?
- if e inc b option_array+18 ;write previous option if it is
-
- ;check if subchart exists and if it can be selected
-
- a1:
- mov dx,w box_save ;load occupied flag
- cmp w subchart_link,0 ;is user choosing a subchart?
- jne >a2 ;check if subchart exists if yes
- or dx,dx ;is flowchart dormant?
- jne >b4 ;check for end subchart option if not
- a2:
- mov ax,w routes+child ;load child chart
- cmp ax,first_box ;is there a existing subchart?
- jb >a4 ;check for up option if not
-
- ;check if subchart is step child and if stack is full
-
- mov bx,parent ;load parent offset
- call get_box_par ;get parent of child
- cmp ax,bp ;is it a step child chart?
- je >a1 ;add option if it is
- cmp w sub_stack,o bottom_stack ;is stack full?
- je >a4 ;check up option if it is
- a1:
- inc b option_array+22 ;write down option
- jmp >a5 ;check for up option
-
- ;check if subchart option is available
-
- a4:
- or dx,dx ;can a subchart be created?
- jne >a3 ;check for up option if not
- cmp w sub_stack,top_stack ;is stack empty?
- jne >a1 ;check for parent box if not
- call check_memory ;check if sufficient memory
- jc >a5 ;don't allow subcharts or loading if not
- inc b option_array+20 ;write create subchart option
- cmp b chart_active,080h ;is chart in interrupt?
- if ne inc b option_array+40 ;add load chart option
-
- ;check if up option is available
-
- a5:
- or dx,dx ;is flowchart dormant?
- je >a1 ;check if on subchart level if it is
- a3:
- cmp w box_to_subchart,0 ;is user choosing a subchart?
- jne >a1 ;check if parent of box if not
-
- ;write view function to options
-
- b4:
- inc b option_array+32 ;write view main box option
- b5:
- jmp long >b3 ;add goto box option
- a1:
- cmp w routes+parent,0 ;is is there a parent chart?
- if ne inc b option_array+24 ;write up option if there is
-
- ;check if flowchart is dormant
-
- or dx,dx ;is it?
- jne b4 ;add view box function if not
- cmp w sub_stack,top_stack ;is user viewing a copied subchart?
- jne b5 ;check for goto option if yes
- cmp w current_route,0 ;are any routes selected?
- jne >b2 ;check for end subchart option if yes
-
- ;check for any branched routes
-
- mov w branch_route_count,0 ;clear count
- mov si,no ;load no route
-
- ;check if there is a route
-
- a1:
- mov w[si+option_routes],0 ;clear extra route option
- mov bx,si ;load route offset
- call get_current_box_par ;get route parameter
- cmp ax,1 ;is there one?
- jbe >a2 ;move to next route if not
- cmp ax,bp ;is route outstanding route?
- je >a2 ;don't count this route if it is
-
- ;check if route is branch
-
- inc w branch_route_count ;increment count
- mov w[si+option_routes],1 ;add extra route option
- mov w first_branch_route,si ;store first branch route
- a2:
- sub si,2 ;move to next route
- jne a1 ;decrement loop count
- cmp w branch_route_count,0 ;are there any branches from box?
- if ne inc b option_array+26 ;write relinquish branch option
-
- ;check if end subchart option is available
-
- b2:
- mov ax,w route_flag ;load route exists but not selected flag
- add ax,w insert_mode ;add it to occupied flag
- or ax,ax ;is anything else going on?
- jne >a1 ;check insert subchart option if yes
- cmp w routes+parent,0 ;is this a subchart?
- if ne inc b option_array+28 ;write end subchart option if it is
-
- ;check if select subchart option is available
-
- a1:
- cmp w box_to_subchart,0 ;can a subchart be selected?
- jne >a1 ;check if flowchart is dormant if not
- call check_memory ;check if sufficient memory
- if nc inc b option_array+30 ;write copy subchart option
- inc b option_array+42 ;add xchange box function option
- a1:
- cmp w box_save,0 ;is flowchart dormant?
- if e inc b option_array+36 ;add ammend descripter option if it is
-
- ;check if 'goto box' option is available
-
- b3:
- cmp w insert_mode,0 ;is flowchart dormant?
- jne >a1 ;check ammend option if not
- inc b option_array+34 ;write goto box option
- inc b option_array+44 ;write search option
-
- ;check if forward option is available
-
- b1:
- cmp w insert_mode,0 ;is flowchart dormant?
- jne >a1 ;set route select if not
- test b flag,1 ;are there any other route options?
- if ne inc b option_array+46 ;add forward option
-
- ;initialise selected route variable
-
- a1:
- mov ax,w current_route ;load route select
- mov w route,ax ;store it
- or ax,ax ;is route single?
- if e add w route,2 ;make route select simple box route
- ret ;exit
-
- ;end